//
//  CTUserViewController.m
//  ConstellationTalk_0.1
//
//  Created by riley on 15/4/29.
//  Copyright (c) 2015年 riley chu. All rights reserved.
//

#import "CTUserViewController.h"
#import "CTSetViewController.h"
#import "CTLoginViewController.h"
#import "CTFenceUserViewController.h"
#import "CTFollowUserViewController.h"
#import "CTTabBarController.h"
#import "CTUserWebViewController.h"
#import "CTCommentViewController.h"
#import "CTLogin.h"

//config
#import "CTHeader.h"

//view
#import "CTUserView.h"

//logic
#import "CTUserLogic.h"
#import "CTRequestUtil.h"
#import "CTLogic.h"

//model
#import "CTShareItem.h"

//function
#import "CTDebugManager.h"
#import "CTGenRequestData.h"
#import "CTUser.h"
#import "CTTextManager.h"
#import "CTShare.h"
#import "CTShareView.h"
#import "CTMoreView.h"
#import "CTRemindView.h"
#import "CTAppLanguage.h"
#import "CTActivitorView.h"
#import "CTDataGenerator.h"
#import "CTTextManager.h"
#import "CTImageProcessing.h"
#import "MobClick.h"

//tool
#import "UIImageView+MJWebCache.h"
#import "MJPhotoBrowser.h"
#import "MJPhoto.h"
#import "AFNetworkReachabilityManager.h"

static NSInteger userFlipNumber = 0;

typedef enum{
    ReportTypeReport = 1,
    ReportTypeDelete
}ReportType;

@interface CTUserViewController ()<CTUserViewDelegate,CTShareViewDelegate,CTMoreViewDelegate,UIAlertViewDelegate>
{
    CTUserView * userView;
    
    CTFollowList * currentFollowListItem;
    
    CTUserLogic * userLogic;
    CTLogic * logic;
    
    ReportType reportType;
    
    CTShareView * shareView;
    CTActivitorView * acView;
    
    UIView * loginBackGroundView;
    UIView * loadingView;
    
    UIImage     *shareImage;
}
@end

@implementation CTUserViewController
@synthesize userItem,pushType,userUid,levelType;


- (void)dealloc
{
    
    
    [loginBackGroundView removeFromSuperview];
    loginBackGroundView = nil;
    
    [loadingView removeFromSuperview];
    loadingView = nil;
    
    
    [shareView removeFromSuperview];
    shareView = nil;
    
    [acView removeFromSuperview];
    acView = nil;
    
    [userView removeFromSuperview];
    userView.delegate = nil;
    userView = nil;
    
    logic = nil;
    currentFollowListItem = nil;
    
    userUid = nil;
    userItem = nil;
    
    userLogic = nil;
    
    shareImage  = nil;
    
    [[NSNotificationCenter defaultCenter] removeObserver:self name:CTLoginSuccessNotification object:nil];
    
    [[NSNotificationCenter defaultCenter] removeObserver:self name:CT_NOTI_DELETE_PUBLISH_SUCCESS object:nil];
    
    [[NSNotificationCenter defaultCenter] removeObserver:self name:CT_NOTI_FOLLOWING_SUCCESS object:nil];
    [[NSNotificationCenter defaultCenter] removeObserver:self name:CT_NOTI_CANCEL_FOLLOWING_SUCCESS object:nil];
    
    [[NSNotificationCenter defaultCenter] removeObserver:self name:CT_NOTI_LIKE_SUCCESS object:nil];
    [[NSNotificationCenter defaultCenter] removeObserver:self name:CT_NOTI_CANCEL_LIKE_SUCCESS object:nil];
    
    [[NSNotificationCenter defaultCenter] removeObserver:self name:CT_NOTI_PUBLISH_COMMENT_SUCCESS object:nil];
    
    [[NSNotificationCenter defaultCenter] removeObserver:self name:CT_NOTI_DELETE_COMMENT_SUCCESS object:nil];
    
    [[NSNotificationCenter defaultCenter] removeObserver:self name:CT_NOTI_PUBLISH_SUCCESS object:nil];
    
    [CTDebugManager showDebugLogInfo:@"dealloc : CTUserViewController Is Removed!!!"];
}

- (instancetype)init
{
    self = [super init];
    if (self) {
        
        userLogic = [[CTUserLogic alloc] init];
        logic = [[CTLogic alloc] init];
        
        //注册登录时间
        [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(loginSuccess:) name:CTLoginSuccessNotification object:nil];
        
        //删除发布内容
        [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(deletePublishSuccessed:) name:CT_NOTI_DELETE_PUBLISH_SUCCESS object:nil];
        
        //关注成功，从新刷新数据库数据
        [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(followPersonSuccess:) name:CT_NOTI_FOLLOWING_SUCCESS object:nil];
        [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(cancelFollowPersonSuccess:) name:CT_NOTI_CANCEL_FOLLOWING_SUCCESS object:nil];
        
        //点赞成功，从新刷新数据库数据
        [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(likePersonSuccess:) name:CT_NOTI_LIKE_SUCCESS object:nil];
        [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(cancelLikePersonSuccess:) name:CT_NOTI_CANCEL_LIKE_SUCCESS object:nil];
        
        //评论成功
        [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(publishCommentSuccessed:) name:CT_NOTI_PUBLISH_COMMENT_SUCCESS object:nil];
        
        //删除评论
        [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(deleteCommentSuccessed:) name:CT_NOTI_DELETE_COMMENT_SUCCESS object:nil];
        
        //注册发布内容通知
        [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(publishSuccess:) name:CT_NOTI_PUBLISH_SUCCESS object:nil];
    }
    return self;
}

-(void)viewWillAppear:(BOOL)animated
{
    [super viewWillAppear:animated];
    //统计
    [MobClick beginLogPageView:@"CTUserViewController"];
//    [userView reloadTables];
//    [userView reloadViews];
}

-(void)viewWillDisappear:(BOOL)animated
{
    [super viewWillDisappear:animated];
    
    //统计
    [MobClick endLogPageView:@"CTUserViewController"];
}


- (void)viewDidLoad {
    [super viewDidLoad];
    
    self.view.backgroundColor = CT_HEADER_WHITE_COLOR;
    
    [self checkNetworkState];
  
}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}


-(void)creatLoadingView{
    loadingView= [[UIView alloc] initWithFrame:self.view.bounds];
    loadingView.backgroundColor = CT_HEADER_WHITE_COLOR;
    [self.view addSubview:loadingView];
    
    UIView * topView = [[UIView alloc]initWithFrame:CGRectMake(0, 0, CT_HEADER_SCREEN_WIDTH, 64)];
    topView.backgroundColor = CT_HEADER_WHITE_COLOR;
    [loadingView addSubview:topView];
    
    UILabel * titleLabel = [[UILabel alloc] initWithFrame:CGRectMake((CT_HEADER_SCREEN_WIDTH-80.0)/2.0, 24, 80, 40)];
    titleLabel.textColor = CT_HEADER_GREEN_COLOR;
    titleLabel.textAlignment = NSTextAlignmentCenter;
    titleLabel.font = [UIFont systemFontOfSize:20];
//    titleLabel.text = [CTAppLanguage localizedStringForKey:@"userView_label_titleLabel" withValue:nil withTable:@"Language"];
    [topView addSubview:titleLabel];
    
    
    UILabel * topBottomLine = [[UILabel alloc]initWithFrame:CGRectMake(0, topView.bounds.size.height-0.5, CT_HEADER_SCREEN_WIDTH, 0.5)];
    topBottomLine.backgroundColor = CT_HEADER_DEEPLINE_COLOR;
    [topView addSubview:topBottomLine];
    if (pushType == CTUserViewControllerPushFromTypeOther) {
        UIButton *backButton = [UIButton buttonWithType:UIButtonTypeCustom];
        backButton.frame = CGRectMake(0, 20, 44, 44);
        [backButton addTarget:self action:@selector(backButtonAction:) forControlEvents:UIControlEventTouchUpInside];
        [backButton setImage:[UIImage imageNamed:CT_HEADER_BACK_IMAGE] forState:UIControlStateNormal];
        [backButton setImage:[UIImage imageNamed:CT_HEADER_BACK_IMAGE_CLICK] forState:UIControlStateHighlighted];
        [topView addSubview:backButton];
    }
    
    
     CTActivitorView * activitorView = [[CTActivitorView alloc] init];
    [activitorView showMoeMarkActivitorViewOn:self.view];
}




-(void)creatNoDataView
{
    loginBackGroundView = [[UIView alloc] initWithFrame:self.view.bounds];
    loginBackGroundView.backgroundColor = CT_HEADER_WHITE_COLOR;
    [self.view addSubview:loginBackGroundView];
    
    
    UIView * topView = [[UIView alloc]initWithFrame:CGRectMake(0, 0, CT_HEADER_SCREEN_WIDTH, 64)];
    topView.backgroundColor = CT_HEADER_WHITE_COLOR;
    [loginBackGroundView addSubview:topView];
    
    UILabel * titleLabel = [[UILabel alloc] initWithFrame:CGRectMake((CT_HEADER_SCREEN_WIDTH-80.0)/2.0, 24, 80, 40)];
    titleLabel.textColor = CT_HEADER_GREEN_COLOR;
    titleLabel.textAlignment = NSTextAlignmentCenter;
    titleLabel.font = [UIFont systemFontOfSize:20];
 //   titleLabel.text = [CTAppLanguage localizedStringForKey:@"userView_label_titleLabel" withValue:nil withTable:@"Language"];
    [topView addSubview:titleLabel];
    
    
    UILabel * topBottomLine = [[UILabel alloc]initWithFrame:CGRectMake(0, topView.bounds.size.height-0.5, CT_HEADER_SCREEN_WIDTH, 0.5)];
    topBottomLine.backgroundColor = CT_HEADER_DEEPLINE_COLOR;
    [topView addSubview:topBottomLine];
    
    if (pushType == CTUserViewControllerPushFromTypeOther) {
        UIButton *backButton = [UIButton buttonWithType:UIButtonTypeCustom];
        backButton.frame = CGRectMake(0, 20, 44, 44);
        [backButton addTarget:self action:@selector(backButtonAction:) forControlEvents:UIControlEventTouchUpInside];
        [backButton setImage:[UIImage imageNamed:CT_HEADER_BACK_IMAGE] forState:UIControlStateNormal];
        [backButton setImage:[UIImage imageNamed:CT_HEADER_BACK_IMAGE_CLICK] forState:UIControlStateHighlighted];
        [topView addSubview:backButton];
    }
    
    
    
    UIView * backgroundView = [[UIView alloc] initWithFrame:CGRectMake(0, 0, CT_HEADER_SCREEN_WIDTH, 184)];
    backgroundView.backgroundColor = [UIColor clearColor];
    backgroundView.center = self.view.center;
    [loginBackGroundView addSubview:backgroundView];
    
    UIImageView * notLoginInImageView = [[UIImageView alloc] initWithFrame:CGRectMake((CT_HEADER_SCREEN_WIDTH - 90.5)/2.0, 0, 90.5, 108)];
    notLoginInImageView.image = [UIImage imageNamed:@"wangguale"];
    [backgroundView addSubview:notLoginInImageView];
    
    UILabel * remindLabel = [[UILabel alloc] initWithFrame:CGRectMake(0,notLoginInImageView.frame.size.height + 5.0, CT_HEADER_SCREEN_WIDTH, 18.0)];
    remindLabel.textAlignment = NSTextAlignmentCenter;
    remindLabel.font = [UIFont systemFontOfSize:18.0];
    remindLabel.text = [CTAppLanguage localizedStringForKey:@"CTHomePageViewController_Request_Failed" withValue:nil withTable:@"Language"];
    remindLabel.textColor = [UIColor colorWithRed:164/255.0 green:164/255.0 blue:164/255.0 alpha:1.0];
    [backgroundView addSubview:remindLabel];
    
    
    
    UIButton * loginBtn =[UIButton buttonWithType:UIButtonTypeCustom];
    loginBtn.frame = CGRectMake((CT_HEADER_SCREEN_WIDTH - 80)/2.0,notLoginInImageView.frame.size.height + remindLabel.frame.size.height + 5.0+20.0,80,28);
    [loginBtn addTarget:self action:@selector(refreshUserView:) forControlEvents:UIControlEventTouchUpInside];
    [loginBtn setTitleColor:CT_HEADER_GREEN_COLOR forState:UIControlStateNormal];
    loginBtn.layer.borderWidth = 1;
    loginBtn.layer.masksToBounds = YES;
    loginBtn.layer.cornerRadius = 3;
    loginBtn.layer.borderColor = CT_HEADER_GREEN_COLOR.CGColor;
    [loginBtn setTitle:[CTAppLanguage localizedStringForKey:@"CTHomePageViewController_Request_Reload" withValue:nil withTable:@"Language"] forState:UIControlStateNormal];
    loginBtn.titleLabel.font = [UIFont systemFontOfSize:15.0];
    [backgroundView addSubview:loginBtn];
    
    
}



#pragma mark - action -

-(void)backButtonAction:(id)sender
{
    if (levelType == CTUserViewControllerLevelFirst) {
        CTTabBarController * tabbarVC = (CTTabBarController *)self.navigationController.tabBarController;
        [tabbarVC showTabbarWithAnimate:YES];
    }
    
    [self.navigationController popViewControllerAnimated:YES];
}

-(void)refreshUserView:(id)sender
{
    if (loginBackGroundView != nil) {
        [loginBackGroundView removeFromSuperview];
        loginBackGroundView = nil;
    }
    
    
    [self checkNetworkState];
//    [self creatLoadingView];
//    [self sendUserInfoRequest:userUid];
    
}


#pragma mark - request -


-(void)sendUserInfoRequest:(NSString *)uidStr
{
    
    if ([[CTTextManager shareInstance] isBlankString:uidStr] == YES)return;
    
    [userLogic userInfoRequest:[CTGenRequestData genUserRequestItem:uidStr] successCompletionHandler:^{
        dispatch_async(dispatch_get_main_queue(), ^{
            [CTDebugManager showDebugLogInfo:@"获取个人信息成功！"];
            
            [loadingView removeFromSuperview];
            loadingView = nil;
            

            if (userView != nil) {
                [userView removeFromSuperview];
                userView = nil;
                userView.delegate = nil;
            }
                
            
            userView = [[CTUserView alloc] init];
            userView.delegate = self;
            userView.userItem = [CTUser otherUserInfo];
            if (pushType == CTUserViewControllerPushFromTypeDefault)userView.type = CTUserViewPushFromTypeDefault;
            else userView.type = CTUserViewPushFromTypeOther;
            [self.view addSubview:userView];
            
            userFlipNumber = 1;
            [self sendUserListDetailRequest:userUid];

        });
    } failedHandler:^{
        dispatch_async(dispatch_get_main_queue(), ^{
            [CTDebugManager showDebugLogInfo:@"获取个人信息失败！"];
            
            [loadingView removeFromSuperview];
            loadingView = nil;
            
            [self creatNoDataView];
            
            [userView refreshPublishTableEnd];
            [userView refreshPublishCollectionEnd];
            [userView refreshSubjectCollectionEnd];
            
        });
    }];
    
}


-(void)sendUserListDetailRequest:(NSString *)uidStr 
{
    [userLogic userPublishDetailListRequest:[CTGenRequestData genRequestUserPublishDetailListItem:uidStr withFlipNumber:userFlipNumber] successCompletionHandler:^{
        dispatch_async(dispatch_get_main_queue(), ^{
            [CTDebugManager showDebugLogInfo:@"获取个人发布列表成功！"];
            userView.publishArr = [CTDataGenerator generateUserPublishDetailListItems];
            
            [userView refreshPublishTableEnd];
            [userView refreshPublishCollectionEnd];
            [userView refreshSubjectCollectionEnd];
            
        });
    } failedHandler:^{
        dispatch_async(dispatch_get_main_queue(), ^{
            [CTDebugManager showDebugLogInfo:@"获取个人发布列表失败！"];
            
            [userView refreshPublishTableEnd];
            [userView refreshPublishCollectionEnd];
            [userView refreshSubjectCollectionEnd];
            
        });
    }];
}








#pragma mark - check net work state -
-(BOOL)checkNetworkState
{
    __block NSString * descri;
    __block CTRemindView * remindView;
    __block BOOL isCheck = YES;
    
    
    [[AFNetworkReachabilityManager sharedManager] startMonitoring];
    
    [[AFNetworkReachabilityManager sharedManager] setReachabilityStatusChangeBlock:^(AFNetworkReachabilityStatus status) {
        
        dispatch_async(dispatch_get_main_queue(), ^{
            if (status == AFNetworkReachabilityStatusNotReachable) {
                descri = [CTAppLanguage localizedStringForKey:@"remindView_login_networkReachable" withValue:nil withTable:@"Language"];
                remindView = [[CTRemindView alloc] init];
                [remindView showRemindViewOn:self.view withRemindWord:descri];
                
                isCheck = NO;
                
               [self creatNoDataView];
                
            }else if (status == AFNetworkReachabilityStatusUnknown){
                descri = [CTAppLanguage localizedStringForKey:@"remindView_login_networkUnknow" withValue:nil withTable:@"Language"];
                remindView = [[CTRemindView alloc] init];
                [remindView showRemindViewOn:self.view withRemindWord:descri];
                
                isCheck = NO;
                
                [self creatNoDataView];
                
            }
            else{
          
                
                if (pushType == CTUserViewControllerPushFromTypeDefault) {
                    
                    if ([CTLogin isUserLoginState] == NO) {
                        if (userView != nil) {
                            [userView removeFromSuperview];
                            userView = nil;
                            userView.delegate = nil;
                        }
                        userView = [[CTUserView alloc] init];
                        userView.delegate = self;
                        userView.userItem = userItem;
                        userView.type = CTUserViewPushFromTypeDefault;
                        [self.view addSubview:userView];
                    }else{
                        
                        userUid = userItem.uid;
                        [self creatLoadingView];
                        [self sendUserInfoRequest:userUid];
                        
                    }
                    
                }else{
                    
                    [self creatLoadingView];
                    [self sendUserInfoRequest:userUid];
                }
            }
        });
        
    }];
    
    return isCheck;
}













#pragma mark - user view delegate -

-(void)backAction:(CTUserView *)view
{
    if (levelType == CTUserViewControllerLevelFirst) {
        CTTabBarController * tabbarVC = (CTTabBarController *)self.navigationController.tabBarController;
        [tabbarVC showTabbarWithAnimate:YES];
    }
    
    [self.navigationController popViewControllerAnimated:YES];
}

-(void)setsAction:(CTUserView *)view
{
    
    if (pushType == CTUserViewControllerPushFromTypeDefault) {
        CTTabBarController * tabbarVC = (CTTabBarController *)self.navigationController.tabBarController;
        [tabbarVC hideTabbarWithAnimate:YES];
        
        CTSetViewController * setViewVC = [[CTSetViewController alloc] init];
        setViewVC.levelsType = CTSetViewControllerLevelsFirst;
        [self.navigationController pushViewController:setViewVC animated:YES];
    }
    else
    {
        CTSetViewController * setViewVC = [[CTSetViewController alloc] init];
        setViewVC.levelsType = CTSetViewControllerLevelsOther;
        [self.navigationController pushViewController:setViewVC animated:YES];
    }
    
    
}
-(void)loginAction:(CTUserView *)view
{
    CTLoginViewController * loginVC = [[CTLoginViewController alloc] init];
    UINavigationController * loginNav = [[UINavigationController alloc] initWithRootViewController:loginVC];
    loginNav.navigationBarHidden = YES;
    
    [self presentViewController:loginNav animated:YES completion:^{
        
    }];
}

-(void)followAction:(CTUserView *)view
{
    
    
    if (pushType == CTUserViewControllerPushFromTypeDefault) {
        CTTabBarController * tabbarVC = (CTTabBarController *)self.navigationController.tabBarController;
        [tabbarVC hideTabbarWithAnimate:YES];
        
        CTFollowUserViewController * followVC = [[CTFollowUserViewController alloc] init];
        followVC.userUid = userUid;
        followVC.levelsType = CTFollowUserViewControllerLevelsFirst;
        [self.navigationController pushViewController:followVC animated:YES];
    }
    else
    {
        CTFollowUserViewController * followVC = [[CTFollowUserViewController alloc] init];
        followVC.userUid = userUid;
        followVC.levelsType = CTFollowUserViewControllerLevelsOther;
        [self.navigationController pushViewController:followVC animated:YES];
    }
    
}
-(void)fenceAction:(CTUserView *)view
{
    
    
    if (pushType == CTUserViewControllerPushFromTypeDefault) {
        CTTabBarController * tabbarVC = (CTTabBarController *)self.navigationController.tabBarController;
        [tabbarVC hideTabbarWithAnimate:YES];
        
        CTFenceUserViewController * fenceVC = [[CTFenceUserViewController alloc] init];
        fenceVC.userUid = userUid;
        fenceVC.levelsType = CTFenceUserViewControllerLevelsFirst;
        [self.navigationController pushViewController:fenceVC animated:YES];
    }
    else
    {
        CTFenceUserViewController * fenceVC = [[CTFenceUserViewController alloc] init];
        fenceVC.userUid = userUid;
        fenceVC.levelsType = CTFenceUserViewControllerLevelsOther;
        [self.navigationController pushViewController:fenceVC animated:YES];
    }
}

-(void)verifiedWeiboAction:(CTUserView *)view
{
    
    if (pushType == CTUserViewControllerPushFromTypeDefault) {
        CTTabBarController * tabbarVC = (CTTabBarController *)self.navigationController.tabBarController;
        [tabbarVC hideTabbarWithAnimate:YES];
        
        CTUserWebViewController * userWebVC = [[CTUserWebViewController alloc] init];
        userWebVC.userItem = userItem;
        userWebVC.userWebViewType = CTUserWebViewVCTypeVerifiedWeibo;
        userWebVC.levelsType = CTUserWebViewLevelsFirst;
        [self.navigationController pushViewController:userWebVC animated:YES];
    }
    else
    {
        CTUserWebViewController * userWebVC = [[CTUserWebViewController alloc] init];
        userWebVC.userItem = userItem;
        userWebVC.userWebViewType = CTUserWebViewVCTypeVerifiedWeibo;
        userWebVC.levelsType = CTUserWebViewLevelsOther;
        [self.navigationController pushViewController:userWebVC animated:YES];
    }
}

-(void)verifiedShopAction:(CTUserView *)view
{
    if (pushType == CTUserViewControllerPushFromTypeDefault) {
        CTTabBarController * tabbarVC = (CTTabBarController *)self.navigationController.tabBarController;
        [tabbarVC hideTabbarWithAnimate:YES];
        
        CTUserWebViewController * userWebVC = [[CTUserWebViewController alloc] init];
        userWebVC.userItem = userItem;
        userWebVC.userWebViewType = CTUserWebViewVCTypeVerifiedShop;
        userWebVC.levelsType = CTUserWebViewLevelsFirst;
        [self.navigationController pushViewController:userWebVC animated:YES];
    }
    else
    {
        CTUserWebViewController * userWebVC = [[CTUserWebViewController alloc] init];
        userWebVC.userItem = userItem;
        userWebVC.userWebViewType = CTUserWebViewVCTypeVerifiedShop;
        userWebVC.levelsType = CTUserWebViewLevelsOther;
        [self.navigationController pushViewController:userWebVC animated:YES];
    }
}

-(void)attention:(CTUserView *)view withBool:(BOOL)isAttention
{
    if (isAttention == YES) {
        [logic followPersonRequest:[CTGenRequestData genRequestFollowPseronItem:userUid] successCompletionHandler:^{
            dispatch_async(dispatch_get_main_queue(), ^{
                [CTDebugManager showDebugLogInfo:@"关注成功！"];
                 [[NSNotificationCenter defaultCenter] postNotificationName:CT_NOTI_FOLLOWING_SUCCESS object:nil];
            });
        } failedHandler:^{
            dispatch_async(dispatch_get_main_queue(), ^{
                [CTDebugManager showErrorLogInfo:@"关注失败！"];
            });
        }];
    }else{
        [logic cancelFollowPersonRequest:[CTGenRequestData genRequestCancelFollowPseronItem:userUid] successCompletionHandler:^{
            dispatch_async(dispatch_get_main_queue(), ^{
                [CTDebugManager showDebugLogInfo:@"取消关注成功！"];
                 [[NSNotificationCenter defaultCenter] postNotificationName:CT_NOTI_CANCEL_FOLLOWING_SUCCESS object:nil];
            });
        } failedHandler:^{
            dispatch_async(dispatch_get_main_queue(), ^{
                [CTDebugManager showErrorLogInfo:@"取消关注失败！"];
            });
        }];
    }
}





//publish tableview delegate

/**
 *@brief 点击评论总数
 */
- (void)commentCountActionItem:(CTFollowList *)item
{
    if (pushType == CTUserViewControllerPushFromTypeDefault) {
        CTTabBarController * tabbarVC = (CTTabBarController *)self.navigationController.tabBarController;
        [tabbarVC hideTabbarWithAnimate:YES];
        
        CTCommentViewController * commentVC = [[CTCommentViewController alloc] init];
        commentVC.followListItem = item;
        commentVC.levelType = CTCommentViewControllerLevelsFirst;
        [self.navigationController pushViewController:commentVC animated:YES];
        
    }else{
        CTCommentViewController * commentVC = [[CTCommentViewController alloc] init];
        commentVC.followListItem = item;
        commentVC.levelType = CTCommentViewControllerLevelsOther;
        [self.navigationController pushViewController:commentVC animated:YES];
    }
}
/**
 *@brief 点击评论第一条
 */
- (void)commentHitFirstLabelActionItem:(CTFollowList *)item
{
    if (pushType == CTUserViewControllerPushFromTypeDefault) {
        CTTabBarController * tabbarVC = (CTTabBarController *)self.navigationController.tabBarController;
        [tabbarVC hideTabbarWithAnimate:YES];
        
        CTCommentViewController * commentVC = [[CTCommentViewController alloc] init];
        commentVC.followListItem = item;
        commentVC.levelType = CTCommentViewControllerLevelsFirst;
        [self.navigationController pushViewController:commentVC animated:YES];
        
    }else{
        CTCommentViewController * commentVC = [[CTCommentViewController alloc] init];
        commentVC.followListItem = item;
        commentVC.levelType = CTCommentViewControllerLevelsOther;
        [self.navigationController pushViewController:commentVC animated:YES];
    }
}
/**
 *@brief 点击评论第二条
 */
- (void)commentHitSecondLabelActionItem:(CTFollowList *)item
{
    if (pushType == CTUserViewControllerPushFromTypeDefault) {
        CTTabBarController * tabbarVC = (CTTabBarController *)self.navigationController.tabBarController;
        [tabbarVC hideTabbarWithAnimate:YES];
        
        CTCommentViewController * commentVC = [[CTCommentViewController alloc] init];
        commentVC.followListItem = item;
        commentVC.levelType = CTCommentViewControllerLevelsFirst;
        [self.navigationController pushViewController:commentVC animated:YES];
        
    }else{
        CTCommentViewController * commentVC = [[CTCommentViewController alloc] init];
        commentVC.followListItem = item;
        commentVC.levelType = CTCommentViewControllerLevelsOther;
        [self.navigationController pushViewController:commentVC animated:YES];
    }
}
/**
 *@brief 点击评论第一条头像
 */
- (void)commentHitFirstHeadActionItem:(CTComment *) item
{
    if (pushType == CTUserViewControllerPushFromTypeDefault) {
        CTTabBarController * tabbarVC = (CTTabBarController *)self.navigationController.tabBarController;
        [tabbarVC hideTabbarWithAnimate:YES];
        
        CTUserViewController * userVC = [[CTUserViewController alloc] init];
        userVC.pushType = CTUserViewControllerPushFromTypeOther;
        userVC.userUid = item.user.uid;
        userVC.levelType = CTUserViewControllerLevelFirst;
        [self.navigationController pushViewController:userVC animated:YES];
    }
    else
    {
        CTUserViewController * userVC = [[CTUserViewController alloc] init];
        userVC.pushType = CTUserViewControllerPushFromTypeOther;
        userVC.userUid = item.user.uid;
        userVC.levelType = CTUserViewControllerLevelOther;
        [self.navigationController pushViewController:userVC animated:YES];
    }
   
}
/**
 *@brief 点击评论第二条头像
 */
- (void)commentHitSecondHeadActionItem:(CTComment *)item
{
    if (pushType == CTUserViewControllerPushFromTypeDefault) {
        CTTabBarController * tabbarVC = (CTTabBarController *)self.navigationController.tabBarController;
        [tabbarVC hideTabbarWithAnimate:YES];
        
        CTUserViewController * userVC = [[CTUserViewController alloc] init];
        userVC.pushType = CTUserViewControllerPushFromTypeOther;
        userVC.userUid = item.user.uid;
        userVC.levelType = CTUserViewControllerLevelFirst;
        [self.navigationController pushViewController:userVC animated:YES];
    }
    else
    {
        CTUserViewController * userVC = [[CTUserViewController alloc] init];
        userVC.pushType = CTUserViewControllerPushFromTypeOther;
        userVC.userUid = item.user.uid;
        userVC.levelType = CTUserViewControllerLevelOther;
        [self.navigationController pushViewController:userVC animated:YES];
    }
    
}

/**
 *@brief 点击头像
 */
- (void)hitHeadActionItem:(CTFollowList *)item
{
    if (pushType == CTUserViewControllerPushFromTypeDefault) {
        CTTabBarController * tabbarVC = (CTTabBarController *)self.navigationController.tabBarController;
        [tabbarVC hideTabbarWithAnimate:YES];
        
        CTUserViewController * userVC = [[CTUserViewController alloc] init];
        userVC.pushType = CTUserViewControllerPushFromTypeOther;
        userVC.userUid = item.user.uid;
        userVC.levelType = CTUserViewControllerLevelFirst;
        [self.navigationController pushViewController:userVC animated:YES];
    }
    else
    {
        CTUserViewController * userVC = [[CTUserViewController alloc] init];
        userVC.pushType = CTUserViewControllerPushFromTypeOther;
        userVC.userUid = item.user.uid;
        userVC.levelType = CTUserViewControllerLevelOther;
        [self.navigationController pushViewController:userVC animated:YES];
    }
}
/**
 *@brief 点击大图
 */
- (void)hitPicImageBtnActionItem:(CTFollowList *)item withImageView:(UIImageView *)imageView
{
    if ([[CTTextManager shareInstance] isBlankString:item.pic_url]) return;
    
    NSMutableArray * photos = [NSMutableArray arrayWithObjects:0, nil];
    MJPhoto *photo = [[MJPhoto alloc] init];
    photo.image = [CTRequestUtil requestImageWithUrl:item.pic_url]; // 图片路径
    photo.srcImageView = imageView;
    [photos addObject:photo];
    
    //   if (photo.image == nil) return;
    // 2.显示相册
    MJPhotoBrowser *browser = [[MJPhotoBrowser alloc] init];
    browser.photos = photos; // 设置所有的图片
    [browser show];
    photos = nil;
}
/**
 *@brief 点赞
 */
- (void)hitFavourBtnActionItem:(CTFollowList *)item withBool:(BOOL) favBool
{
    //已登录
    if (favBool == YES) {
        [logic likePersonRequest:[CTGenRequestData genRequestLikePseronItem:item.scheme_id] successCompletionHandler:^{
            dispatch_async(dispatch_get_main_queue(), ^{
                [CTDebugManager showDebugLogInfo:@"点赞成功！"];
                //  [[NSNotificationCenter defaultCenter] postNotificationName:CT_NOTI_FOLLOWING_SUCCESS object:nil];
            });
        } failedHandler:^{
            [CTDebugManager showErrorLogInfo:@"点赞失败！"];
        }];
    }else{
        [logic cancelLikePersonRequest:[CTGenRequestData genRequestCancelLikePseronItem:item.scheme_id] successCompletionHandler:^{
            dispatch_async(dispatch_get_main_queue(), ^{
                [CTDebugManager showDebugLogInfo:@"取消点赞成功！"];
               //   [[NSNotificationCenter defaultCenter] postNotificationName:CT_NOTI_CANCEL_FOLLOWING_SUCCESS object:nil];
            });
        } failedHandler:^{
            [CTDebugManager showErrorLogInfo:@"取消点赞失败！"];
        }];
    }
}
/**
 *@brief 点击评论按钮
 */
- (void)hitCommentBtnactionItem:(CTFollowList *)item
{
    if (pushType == CTUserViewControllerPushFromTypeDefault) {
        CTTabBarController * tabbarVC = (CTTabBarController *)self.navigationController.tabBarController;
        [tabbarVC hideTabbarWithAnimate:YES];
        
        CTCommentViewController * commentVC = [[CTCommentViewController alloc] init];
        commentVC.followListItem = item;
        commentVC.levelType = CTCommentViewControllerLevelsFirst;
        [self.navigationController pushViewController:commentVC animated:YES];
        
    }else{
        CTCommentViewController * commentVC = [[CTCommentViewController alloc] init];
        commentVC.followListItem = item;
        commentVC.levelType = CTCommentViewControllerLevelsOther;
        [self.navigationController pushViewController:commentVC animated:YES];
    }
}
/**
 *@brief 点击分享按钮
 */
- (void)hitShareBtnActionItem:(CTFollowList *)item withImage:(UIImage *)img
{
    shareImage = img;
    //已登录
    currentFollowListItem = item;
    
    //share view
    shareView = [[CTShareView alloc] init];
    shareView.delegate = self;
    [shareView showShareViewOn:self.view.window withShareViewType:CTShareViewTypeDefault];
}

/**
 *@brief 点击更多按钮
 */
- (void)hitMoreBtnActionItem:(CTFollowList *)item
{
    currentFollowListItem = item;
    
    CTUserItem * user_item = [CTUser userInfo];
    if ([item.user.uid isEqualToString:user_item.uid]) {
        CTMoreView * moreView = [[CTMoreView alloc] init];
        moreView.delegate = self;
        [moreView showMoreViewOn:self.view.window withMoreViewType:CTMoreViewTypeDefault];
    }else{
        CTMoreView * moreView = [[CTMoreView alloc] init];
        moreView.delegate = self;
        [moreView showMoreViewOn:self.view.window withMoreViewType:CTMoreViewTypeReport];
    }
}
/**
 *@brief 点击点赞的人的头像
 */
- (void)hitFavBtnHeadActionItem:(CTListDetailUser *)item
{
    if (pushType == CTUserViewControllerPushFromTypeDefault) {
        CTTabBarController * tabbarVC = (CTTabBarController *)self.navigationController.tabBarController;
        [tabbarVC hideTabbarWithAnimate:YES];
        
        CTUserViewController * userVC = [[CTUserViewController alloc] init];
        userVC.pushType = CTUserViewControllerPushFromTypeOther;
        userVC.userUid = item.uid;
        userVC.levelType = CTUserViewControllerLevelFirst;
        [self.navigationController pushViewController:userVC animated:YES];
    }
    else
    {
        CTUserViewController * userVC = [[CTUserViewController alloc] init];
        userVC.pushType = CTUserViewControllerPushFromTypeOther;
        userVC.userUid = item.uid;
        userVC.levelType = CTUserViewControllerLevelOther;
        [self.navigationController pushViewController:userVC animated:YES];
    }
}
/**
 *@brief 点击关注按钮
 */
- (void)hitAttentionBtnActionItem:(CTFollowList *)item withBool:(BOOL)attenBool
{
    if (attenBool == YES) {
        [logic followPersonRequest:[CTGenRequestData genRequestFollowPseronItem:item.user.uid] successCompletionHandler:^{
            dispatch_async(dispatch_get_main_queue(), ^{
                [CTDebugManager showDebugLogInfo:@"关注成功！"];
                //  [[NSNotificationCenter defaultCenter] postNotificationName:CT_NOTI_FOLLOWING_SUCCESS object:nil];
            });
        } failedHandler:^{
            dispatch_async(dispatch_get_main_queue(), ^{
                [CTDebugManager showErrorLogInfo:@"关注失败！"];
            });
        }];
    }else{
        [logic cancelFollowPersonRequest:[CTGenRequestData genRequestCancelFollowPseronItem:item.user.uid] successCompletionHandler:^{
            dispatch_async(dispatch_get_main_queue(), ^{
                [CTDebugManager showDebugLogInfo:@"取消关注成功！"];
                //  [[NSNotificationCenter defaultCenter] postNotificationName:CT_NOTI_CANCEL_FOLLOWING_SUCCESS object:nil];
            });
        } failedHandler:^{
            dispatch_async(dispatch_get_main_queue(), ^{
                [CTDebugManager showErrorLogInfo:@"取消关注失败！"];
            });
        }];
    }
}
/**
 *@brief 点击话题
 */
- (void)hitTopicBtnActionItem:(CTTopic *)item
{
    if (pushType == CTUserViewControllerPushFromTypeDefault) {
        CTTabBarController * tabbarVC = (CTTabBarController *)self.navigationController.tabBarController;
      //  [tabbarVC hideTabbarWithAnimate:YES];
        [tabbarVC selectTabbarIndex:0];
    }else{
        CTTabBarController * tabbarVC = (CTTabBarController *)self.navigationController.tabBarController;
        [tabbarVC selectTabbarIndex:0];
        [tabbarVC showTabbarWithAnimate:YES];
        [self.navigationController popToRootViewControllerAnimated:YES];
    }
    
    
    
    [[NSNotificationCenter defaultCenter] postNotificationName:CT_NOTI_JUMP_TO_GROUP object:item];
}


-(void)refreshPTControlPullDown
{
    [self sendUserInfoRequest:userUid];
}

-(void)refreshPTControlPullUp
{
    userFlipNumber ++;
    [self sendUserListDetailRequest:userUid];
}




//publish collectionview delegate

-(void)collectionListViewClickedItem:(CTFollowList *)item
{
    if (pushType == CTUserViewControllerPushFromTypeDefault) {
        CTTabBarController * tabbarVC = (CTTabBarController *)self.navigationController.tabBarController;
        [tabbarVC hideTabbarWithAnimate:YES];
        
        CTCommentViewController * commentVC = [[CTCommentViewController alloc] init];
        commentVC.followListItem = item;
        commentVC.levelType = CTCommentViewControllerLevelsFirst;
        [self.navigationController pushViewController:commentVC animated:YES];
        
    }else{
        CTCommentViewController * commentVC = [[CTCommentViewController alloc] init];
        commentVC.followListItem = item;
        commentVC.levelType = CTCommentViewControllerLevelsOther;
        [self.navigationController pushViewController:commentVC animated:YES];
    }
    
}


-(void)refreshPCControlPullDown
{
    [self sendUserInfoRequest:userUid];
}

-(void)refreshPCControlPullUp
{
    userFlipNumber ++;
    [self sendUserListDetailRequest:userUid];
}

//subject collection delegate

-(void)refreshSCControlPullDown
{
    
}

-(void)refreshSCControlPullUp
{
    
}













#pragma mark - share view delegate -

//试图移除
-(void)viewDidRemoved:(CTShareView *)view
{
    shareView = nil;
    shareView.delegate = nil;
}
//分享到微信朋友圈
- (void)shareViewShareToWechatFriends:(CTShareView *) view withImage:(UIImage *)image
{
    CTShareItem * shareItem = shareItem = [[CTShareItem alloc] init];
    shareItem.img = shareImage;//[CTRequestUtil requestImageWithUrl:currentFollowListItem.pic_url];
    shareItem.defaultContent = currentFollowListItem.text;
    shareItem.descr = currentFollowListItem.text;
    shareItem.descr = [CTAppLanguage localizedStringForKey:@"share_topic_describe" withValue:nil withTable:@"Language"];;
    shareItem.title = [CTAppLanguage localizedStringForKey:@"share_title" withValue:nil withTable:@"Language"];
    shareItem.url = currentFollowListItem.share_url;
    
    
    [CTShare shareItem:shareItem shareChannel:CTShareChannelWechatFriend publishType:CTPublishTypeNews shareSuccessHandler:^{
        dispatch_async(dispatch_get_main_queue(), ^{
            CTRemindView * remindView = [[CTRemindView alloc] init];
            [remindView showRemindViewOn:self.view withRemindWord:[CTAppLanguage localizedStringForKey:@"remindView_Publish_successed" withValue:nil withTable:@"Language"]];
        });
    } shareFailedHandler:^{
        dispatch_async(dispatch_get_main_queue(), ^{
            CTRemindView * remindView = [[CTRemindView alloc] init];
            [remindView showRemindViewOn:self.view withRemindWord:[CTAppLanguage localizedStringForKey:@"remindView_Publish_failed" withValue:nil withTable:@"Language"]];
        });
    }];
}
//分享到QQ空间
- (void)shareViewShareToQQSpace:(CTShareView *)view withImage:(UIImage *)image
{
    CTShareItem * shareItem = shareItem = [[CTShareItem alloc] init];
    UIImage *img = shareImage;//[CTRequestUtil requestImageWithUrl:currentFollowListItem.pic_url];
    CGSize size = CGSizeMake(320, 320);
    shareItem.img = [CTImageProcessing imageCompressionImg:img WithSize:size];
    shareItem.content = currentFollowListItem.text;
    shareItem.defaultContent = currentFollowListItem.text;
    shareItem.descr = [CTAppLanguage localizedStringForKey:@"share_pic_describe" withValue:nil withTable:@"Language"];;
    shareItem.title = [CTAppLanguage localizedStringForKey:@"share_title" withValue:nil withTable:@"Language"];
    shareItem.url = currentFollowListItem.share_url;
    
    [CTShare shareItem:shareItem shareChannel:CTShareChannelQQSpace publishType:CTPublishTypeImage shareSuccessHandler:^{
        dispatch_async(dispatch_get_main_queue(), ^{
            CTRemindView * remindView = [[CTRemindView alloc] init];
            [remindView showRemindViewOn:self.view withRemindWord:[CTAppLanguage localizedStringForKey:@"remindView_Publish_successed" withValue:nil withTable:@"Language"]];
        });
    } shareFailedHandler:^{
        dispatch_async(dispatch_get_main_queue(), ^{
            CTRemindView * remindView = [[CTRemindView alloc] init];
            [remindView showRemindViewOn:self.view withRemindWord:[CTAppLanguage localizedStringForKey:@"remindView_Publish_failed" withValue:nil withTable:@"Language"]];
        });
    }];
}
//分享到新浪微博
- (void)shareViewShareToSina:(CTShareView *)view withImage:(UIImage *)image
{
    CTShareItem * shareItem = shareItem = [[CTShareItem alloc] init];
    shareItem.img = shareImage;//[CTRequestUtil requestImageWithUrl:currentFollowListItem.pic_url];
    shareItem.content = currentFollowListItem.text;
    shareItem.defaultContent = currentFollowListItem.text;
    shareItem.descr = [CTAppLanguage localizedStringForKey:@"share_pic_describe" withValue:nil withTable:@"Language"];;
    shareItem.title = [CTAppLanguage localizedStringForKey:@"share_title" withValue:nil withTable:@"Language"];
    shareItem.url = currentFollowListItem.share_url;
    [CTShare sinaBtnAction:shareItem shareSuccessHandler:^{
        dispatch_async(dispatch_get_main_queue(), ^{
            CTRemindView * remindView = [[CTRemindView alloc] init];
            [remindView showRemindViewOn:self.view withRemindWord:[CTAppLanguage localizedStringForKey:@"remindView_Publish_successed" withValue:nil withTable:@"Language"]];
        });
    } shareFailedHandler:^{
        dispatch_async(dispatch_get_main_queue(), ^{
            CTRemindView * remindView = [[CTRemindView alloc] init];
            [remindView showRemindViewOn:self.view withRemindWord:[CTAppLanguage localizedStringForKey:@"remindView_Publish_failed" withValue:nil withTable:@"Language"]];
        });
    }];

//    [CTShare shareItem:shareItem shareChannel:CTShareChannelSina publishType:CTPublishTypeImage shareSuccessHandler:^{
//        dispatch_async(dispatch_get_main_queue(), ^{
//            CTRemindView * remindView = [[CTRemindView alloc] init];
//            [remindView showRemindViewOn:self.view withRemindWord:[CTAppLanguage localizedStringForKey:@"remindView_Publish_successed" withValue:nil withTable:@"Language"]];
//        });
//    } shareFailedHandler:^{
//        dispatch_async(dispatch_get_main_queue(), ^{
//            CTRemindView * remindView = [[CTRemindView alloc] init];
//            [remindView showRemindViewOn:self.view withRemindWord:[CTAppLanguage localizedStringForKey:@"remindView_Publish_failed" withValue:nil withTable:@"Language"]];
//        });
//    }];
}
//分享到微信
- (void)shareViewShareToWeChat:(CTShareView *)view withImage:(UIImage *)image
{
    CTShareItem * shareItem = shareItem = [[CTShareItem alloc] init];
    shareItem.img = shareImage;//[CTRequestUtil requestImageWithUrl:currentFollowListItem.pic_url];
    shareItem.defaultContent = currentFollowListItem.text;
    shareItem.descr = currentFollowListItem.text;
    shareItem.content = [CTAppLanguage localizedStringForKey:@"share_pic_describe" withValue:nil withTable:@"Language"];
    shareItem.title = [CTAppLanguage localizedStringForKey:@"share_title" withValue:nil withTable:@"Language"];
    shareItem.url = currentFollowListItem.share_url;
    
    [CTShare shareItem:shareItem shareChannel:CTShareChannelWechat publishType:CTPublishTypeNews shareSuccessHandler:^{
        dispatch_async(dispatch_get_main_queue(), ^{
            CTRemindView * remindView = [[CTRemindView alloc] init];
            [remindView showRemindViewOn:self.view withRemindWord:[CTAppLanguage localizedStringForKey:@"remindView_Publish_successed" withValue:nil withTable:@"Language"]];
        });
    } shareFailedHandler:^{
        dispatch_async(dispatch_get_main_queue(), ^{
            CTRemindView * remindView = [[CTRemindView alloc] init];
            [remindView showRemindViewOn:self.view withRemindWord:[CTAppLanguage localizedStringForKey:@"remindView_Publish_failed" withValue:nil withTable:@"Language"]];
        });
    }];
}
//分享到QQ
- (void)shareViewShareToQQ:(CTShareView *)view withImage:(UIImage *)image
{
    
    CTShareItem * shareItem = shareItem = [[CTShareItem alloc] init];
    UIImage *img = shareImage;//[CTRequestUtil requestImageWithUrl:currentFollowListItem.pic_url];
    CGSize size = CGSizeMake(320, 320);
    shareItem.img = [CTImageProcessing imageCompressionImg:img WithSize:size];
    shareItem.defaultContent = currentFollowListItem.text;
    shareItem.descr = currentFollowListItem.text;
    shareItem.content = [CTAppLanguage localizedStringForKey:@"share_pic_describe" withValue:nil withTable:@"Language"];
    shareItem.title = [CTAppLanguage localizedStringForKey:@"share_title" withValue:nil withTable:@"Language"];
    shareItem.url =  currentFollowListItem.share_url;
    
    [CTShare shareItem:shareItem shareChannel:CTShareChannelQQ publishType:CTPublishTypeNews shareSuccessHandler:^{
        dispatch_async(dispatch_get_main_queue(), ^{
            CTRemindView * remindView = [[CTRemindView alloc] init];
            [remindView showRemindViewOn:self.view withRemindWord:[CTAppLanguage localizedStringForKey:@"remindView_Publish_successed" withValue:nil withTable:@"Language"]];
        });
    } shareFailedHandler:^{
        dispatch_async(dispatch_get_main_queue(), ^{
            CTRemindView * remindView = [[CTRemindView alloc] init];
            [remindView showRemindViewOn:self.view withRemindWord:[CTAppLanguage localizedStringForKey:@"remindView_Publish_failed" withValue:nil withTable:@"Language"]];
        });
    }];
}



#pragma mark - more view delegate -

- (void)moreViewDelBtnAction:(CTMoreView *)view
{
    reportType = ReportTypeDelete;
    
    NSString * titleStr = [CTAppLanguage localizedStringForKey:@"CTHomePageViewController_Alert_Remind" withValue:nil withTable:@"Language"];
    NSString * messageStr = [CTAppLanguage localizedStringForKey:@"CTHomePageViewController_Alert_Message_Delete" withValue:nil withTable:@"Language"];
    NSString * confirmStr = [CTAppLanguage localizedStringForKey:@"CTHomePageViewController_Alert_Confirm" withValue:nil withTable:@"Language"];
    NSString * cancelStr = [CTAppLanguage localizedStringForKey:@"CTHomePageViewController_Alert_Cancel" withValue:nil withTable:@"Language"];
    
    UIAlertView * alertView = [[UIAlertView alloc] initWithTitle:titleStr message:messageStr delegate:self cancelButtonTitle:cancelStr otherButtonTitles:confirmStr, nil];
    [alertView show];
    
    view = nil;
}
- (void)moreViewreportBtnAction:(CTMoreView *)view
{
    reportType = ReportTypeReport;
    
    NSString * titleStr = [CTAppLanguage localizedStringForKey:@"CTHomePageViewController_Alert_Remind" withValue:nil withTable:@"Language"];
    NSString * messageStr = [CTAppLanguage localizedStringForKey:@"CTHomePageViewController_Alert_Message_Report" withValue:nil withTable:@"Language"];
    NSString * confirmStr = [CTAppLanguage localizedStringForKey:@"CTHomePageViewController_Alert_Confirm" withValue:nil withTable:@"Language"];
    NSString * cancelStr = [CTAppLanguage localizedStringForKey:@"CTHomePageViewController_Alert_Cancel" withValue:nil withTable:@"Language"];
    
    UIAlertView * alertView = [[UIAlertView alloc] initWithTitle:titleStr message:messageStr delegate:self cancelButtonTitle:cancelStr otherButtonTitles:confirmStr, nil];
    [alertView show];
    
    view = nil;
}
- (void)moreViewCanacelBtnAction:(CTMoreView *)view
{
    
    view = nil;
}
- (void)moreViewDidRemoved:(CTMoreView *)view
{
    view = nil;
}

#pragma mark - alert view delegate -

- (void)alertView:(UIAlertView *)alertView clickedButtonAtIndex:(NSInteger)buttonIndex
{
    
    if (buttonIndex == 1) {
        if (reportType == ReportTypeReport) {
            //举报
            acView = [[CTActivitorView alloc] init];
            [acView showActivitorViewOn:self.view withType:CTActivitorViewDefault];
            
            [logic reportRequest:[CTGenRequestData genRequestReportItem:currentFollowListItem.scheme_id] successCompletionHandler:^{
                dispatch_async(dispatch_get_main_queue(), ^{
                    
                    [acView removeActivitorView];
                    acView = nil;
                    
                    CTRemindView * remindView = [[CTRemindView alloc] init];
                    [remindView showRemindViewOn:self.view withRemindWord:[CTAppLanguage localizedStringForKey:@"CTHomePageViewController_Report_Success" withValue:nil withTable:@"Language"]];
                    
                });
            } failedHandler:^{
                dispatch_async(dispatch_get_main_queue(), ^{
                    
                    [acView removeActivitorView];
                    acView = nil;
                    
                    CTRemindView * remindView = [[CTRemindView alloc] init];
                    [remindView showRemindViewOn:self.view withRemindWord:[CTAppLanguage localizedStringForKey:@"CTHomePageViewController_Report_Failed" withValue:nil withTable:@"Language"]];
                    
                });
            }];
        }else{
            //删除自己的发布内容
            
            acView = [[CTActivitorView alloc] init];
            [acView showActivitorViewOn:self.view withType:CTActivitorViewDefault];
            
            [logic deletePublishRequest:[CTGenRequestData genRequestDeletePublishItem:currentFollowListItem.scheme_id] successCompletionHandler:^{
                dispatch_async(dispatch_get_main_queue(), ^{
                    
                    [[NSNotificationCenter defaultCenter] postNotificationName:CT_NOTI_DELETE_PUBLISH_SUCCESS object:nil];
                    
                    [acView removeActivitorView];
                    acView = nil;
                    
                    CTRemindView * remindView = [[CTRemindView alloc] init];
                    [remindView showRemindViewOn:self.view withRemindWord:[CTAppLanguage localizedStringForKey:@"CTHomePageViewController_Delete_Success" withValue:nil withTable:@"Language"]];
                    
                });
            } failedHandler:^{
                dispatch_async(dispatch_get_main_queue(), ^{
                    
                    
                    [acView removeActivitorView];
                    acView = nil;
                    
                    CTRemindView * remindView = [[CTRemindView alloc] init];
                    [remindView showRemindViewOn:self.view withRemindWord:[CTAppLanguage localizedStringForKey:@"CTHomePageViewController_Delete_Failed" withValue:nil withTable:@"Language"]];
                    
                });
            }];
            
        }
    }
    
    alertView.delegate = nil;
    [alertView removeFromSuperview];
    alertView = nil;
}




#pragma mark - notification -

-(void)loginSuccess:(id)sender
{
   
    userItem = [CTUser userInfo];
    userUid = userItem.uid;
    [self creatLoadingView];
    [self sendUserInfoRequest:userUid];
}

-(void)deletePublishSuccessed:(id)sender
{
    
    [self sendUserInfoRequest:userUid];
}

-(void)followPersonSuccess:(id)sender
{
    [self sendUserInfoRequest:userUid];
}

-(void)cancelFollowPersonSuccess:(id)sender
{
    [self sendUserInfoRequest:userUid];
}

-(void)likePersonSuccess:(id)sender
{
    
    [self sendUserInfoRequest:userUid];
}

-(void)cancelLikePersonSuccess:(id)sender
{
    [self sendUserInfoRequest:userUid];
}

-(void)publishCommentSuccessed:(id)sender
{
    [self sendUserInfoRequest:userUid];
}

-(void)deleteCommentSuccessed:(id)sender
{
    [self sendUserInfoRequest:userUid];
}

-(void)publishSuccess:(id)sender
{
    [self sendUserInfoRequest:userUid];
}

@end
